
\documentclass{article}

\usepackage{geometry} 
\usepackage{booktabs}         %for tables
%\geometry{letterpaper} 
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{hyperref}         %use hyperlink
\usepackage{epstopdf}
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}
\providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}\makeatletter
\def\verbatim@font{\ttfamily\scriptsize}
\makeatother
\begin{document}


\section{Making the source code really
reproducible}\label{making-the-source-code-really-reproducible}

To make the do-file really reproducible, we have to make sure it does
not access the data that is already loaded in Stata. Think about it, if
you execute a do-file on a data that is already loaded and you have been
working on it, can you ensure that re-executing the do-file creates the
same results again? you might have done some changes outside of the
do-file on the data - such as droping a record - which makes the results
ireproducible.

The solution would be to \textbf{run the do-file in a cleared workspace}
to ensure the do-file does not access the data that is already loaded.
\textbf{MarkDoc} can take a do-file and execute the code in a cleared
workspace and produce the dynamic document. This is a very different
engine compared to rendering a smcl-log to a dynamic document.

If the do-file return an error, \textbf{MarkDoc} still create the
dynamic document until the point the error occured. To run this do-file,
first load the \textbf{auto} dataset in Stata. Then call
\textbf{\texttt{markdoc}} to produce the dynamic document. You should
get an error the \texttt{no\ variables\ defined}, which means your
do-file does not load the data, although the data are loaded in your
Stata.

\end{document}



